import { request } from '@/request'
import { addCategoryData, categoryItem, categoryParams, categoryResult } from '@/types/category'

export function getCategoryListApi(params: categoryParams) {
  return request<categoryResult>(
    '/admin/category/page', "get", params
  )
}

export function updateStatusApi(id: number, status: number,) {
  return request(
    `/admin/category/status/${status}`, "post", { id }, true
  )
}

export function addCategoryApi(data: addCategoryData) {
  return request(
    '/admin/category', "post", data
  )
}

export function getCategoryDetailApi(id: number) {
  return request<categoryItem>(
    `/admin/category/detail`, "post", { id }
  )
}

export function updateCategoryApi(data: addCategoryData) {
  return request(
    '/admin/category', "put", data
  )
}

export function deleteCategoryApi(id: number) {
  return request(
    '/admin/category/delete', "post", { id }
  )
}

export function getCategoryListByTypeApi(type: number = 1) {
  return request<categoryItem[]>(
    '/admin/category/list', "get", { type }
  )
}